module QuestionVersionsHelper
  def set_alias_form_qved(qv)
    if !qv.remark.nil?
      set_alias("form_qvedr_#{qv.remark_id}", "form_qved_#{qv.id}") +
        set_alias("form_redt_#{qv.remark_id}", "form_qvedr_#{qv.remark_id}")
    else
      set_alias("form_qvedq_#{qv.question_id}", "form_qved_#{qv.id}") +
        set_alias("form_qed_#{qv.question_id}", "form_qvedq_#{qv.question_id}")
    end
  end

  def question_field_label(qf, f)
    f.label :"#{qf.position}", qf.name
  end

  def question_field_tag(qf, f)
    if qf.max_len < 0
      f.select :"#{qf.position}", (
      #(
        qf.question_type.question_fields.where(
          :position.gte => qf.min_len, :position.lte => qf.max_len)
        .collect{ |i| [ i.name, i.name ] }
      )
      #"#{qf.question_type.question_fields.entries}"
    elsif qf.max_len < 30
      f.text_field :"#{qf.position}"
    else
      f.text_area :"#{qf.position}"
    end
  end
end
